package com.dn.apiopen.service.impl.inner;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dn.apiopen.common.ErrorCode;
import com.dn.apiopen.exception.BusinessException;
import com.dn.apiopen.mapper.InterfaceInfoMapper;
import com.dn.apiopen.service.InterfaceInfoService;
import com.dn.dncommon.model.entity.InterfaceInfo;
import com.dn.dncommon.service.InnerInterfaceInfoService;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * @author 18398
 * @description 针对表【interface_info(接口信息)】的数据库操作Service实现
 * @createDate 2024-03-17 16:22:31
 */
//@Service
@DubboService
public class InnerInterfaceInfoServiceImpl implements InnerInterfaceInfoService {

    @Resource
    private InterfaceInfoMapper interfaceInfoMapper;


    /**
     * 校验接口是否存在
     *
     * @param url
     * @param method
     * @return
     */
    @Override
    public InterfaceInfo getInterfaceInfo(String url, String method) {
        if (StringUtils.isAnyBlank(url, method)) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        LambdaQueryWrapper<InterfaceInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(InterfaceInfo::getUrl, url);
        wrapper.eq(InterfaceInfo::getMethod, method);
        return interfaceInfoMapper.selectOne(wrapper);
    }
}




